package com.jxc.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class FirstServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        // 接收请求发来的参数
        String name = req.getParameter("name");
        String html = "<h1>hi "+name+" !</h1></hr>";
        System.out.println("浏览器返回的响应数据为："+html);
        // 将html发送回浏览器
        PrintWriter out = resp.getWriter();
        out.print(html);
    }

}
